// pages/list/list.js
Page({
  come_baby: function (event) {
    wx.switchTab({
      url: '../index/index',
    })
  },

  /**
   * 页面的初始数据
   */
  data: {
    list: [],
    phone: '',
    idx: '',
    newlist: {
      path: '',
      name: '',
      time: ''
    }

  },
  openSlider: function (e) {
    if (this.data.open) {
      this.setData({
        open: false
      });
    } else {
      this.setData({
        open: true
      });
    }
  },
  tap_start: function (e) {

    this.data.mark = this.data.newmark = e.touches[0].pageX;
  },
  tap_drag: function (e) {

    this.data.newmark = e.touches[0].pageX;

    if (this.data.mark < this.data.newmark) {
      this.istoright = true;
    }

    if (this.data.mark > this.data.newmark) {
      this.istoright = false;
    }
    this.data.mark = this.data.newmark;
  },
  tap_end: function (e) {
    this.data.mark = 0;
    this.data.newmark = 0;
    if (this.istoright) {
      this.setData({
        open: true
      });
    } else {
      this.setData({
        open: false
      });
    }
  },

  show: function () {
    this.setData({
      isShowSideslip: true
    })
  },
  offSideslipMen: function () {
    this.setData({
      isShowSideslip: false
    })
  },
  itemClick: function (e) {
    var tapId = e.currentTarget.id;
    var index = this;
    for (var i = 0; i < index.data.sideslipMenuArr.length; i++) {
      if (tapId == i) {
        wx.showToast({
          title: index.data.sideslipMenuArr[i],
          icon: 'none',
          image: '',
          duration: 1000,
          mask: true,
          success: function (res) {},
          fail: function (res) {},
          complete: function (res) {},
        })
      }
    }
  },


  powerDrawer: function (e) {
    var currentStatu = e.currentTarget.dataset.statu;
    this.util(currentStatu)
  },
  util: function (currentStatu) {

    var animation = wx.createAnimation({
      duration: 200,
      timingFunction: "linear",
      delay: 0
    });

    this.animation = animation;
    animation.translateX(0).step();

    this.setData({
      animationData: animation.export()
    })
    setTimeout(function () {
      animation.translateX(220).step()
      this.setData({
        animationData: animation
      })
      if (currentStatu == "close") {
        this.setData({
          showModalStatus: false
        });
      }
    }.bind(this), 200)

    if (currentStatu == "open") {
      this.setData({
        showModalStatus: true
      });
    }
  },
  submit: function (e) {
    this.setData({
      showModal: true,
      idx: e.target.dataset.index
    })
  },
  preventTouchMove: function () {

  },

  close_mask: function () {
    this.setData({
      showModal: false
    })
  },
  genghuan() {
    wx.request({
      url: 'http://111.173.104.245:4000/api/user/zhanshi',
      success: (res) => {
        wx.showToast({
          title: '偶遇更多',
          icon: 'loading',
          duration: 2000

        })
        this.setData({
          list: res.data.data
        })
      }
    })
  },
  getData() {
    wx.request({
      url: 'http://111.173.104.245:4000/api/user/zhanshi',
      success: (res) => {
        this.setData({
          list: res.data.data
        })
      }
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.getData()
    var app = getApp();
    var categoryInfo = app.globalData.categoryInfo;
    this.setData({
      phone: categoryInfo.phone,
    })
  },




  quit: function () {

    wx.removeStorage({

      key: 'categoryInfo',

      success(res) {

        wx.showModal({

          title: '提示',

          content: '请确定是否退出',

          cancelText: '取消',

          confirmText: '退出',

          confirmColor: '#000000',

          cancelColor: '#576b95',

          success(res) {

            if (res.confirm) {

              wx.reLaunch({

                url: '/pages/index/index',

              })

            } else if (res.cancel) {


            }

          }

        })



      }

    })



  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})